<?php
require_once("lib/db_connection.php");
$job_id = $_GET['job_id'];
$company_id = $_SESSION['company_id'];

$result_select = mysql_query("SELECT * FROM rou_job_loc_tbl WHERE job_id='".$job_id."'")
or die("SELECT LOCS ".mysql_error());

$result_num = mysql_query("SELECT * FROM route_tbl WHERE route_id='".$job_id."'")
or die("SELECT NUM ".mysql_error());
$row_num = mysql_fetch_array($result_num);

$dr1_id = $row_num['dr1_id'];
$dr2_id = $row_num['dr2_id'];
$asst1_id = $row_num['asst1_id'];
$asst2_id = $row_num['asst2_id'];

$result_dr1 = mysql_query("SELECT * FROM employee_tbl WHERE autoid='".$dr1_id."'")
or die("SELECT NUM ".mysql_error());
$row_dr1 = mysql_fetch_array($result_dr1);

if($dr1_id=='0')
{
	$dr1 = 'None';
}

if($dr1_id!='0')
{
	$dr1 = $row_dr1['lname'].','.$row_dr1['fname'];
}

$result_dr2 = mysql_query("SELECT * FROM employee_tbl WHERE autoid='".$dr2_id."'")
or die("SELECT NUM ".mysql_error());
$row_dr2 = mysql_fetch_array($result_dr2);

if($dr2_id=='0')
{
	$dr2 = 'None';
}

if($dr2_id!='0')
{
	$dr2 = $row_dr2['lname'].','.$row_dr2['fname'];
}

$result_asst1 = mysql_query("SELECT * FROM employee_tbl WHERE autoid='".$asst1_id."'")
or die("SELECT NUM ".mysql_error());
$row_asst1 = mysql_fetch_array($result_asst1);

if($asst1_id=='0')
{
	$asst1 = 'None';
}

if($asst1_id!='0')
{
	$asst1 = $row_asst1['lname'].','.$row_asst1['fname'];
}

$result_asst2 = mysql_query("SELECT * FROM employee_tbl WHERE autoid='".$asst2_id."'")
or die("SELECT NUM ".mysql_error());
$row_asst2 = mysql_fetch_array($result_asst2);

if($asst2_id=='0')
{
	$asst2 = 'None';
}

if($asst2_id!='0')
{
	$asst2 = $row_asst2['lname'].','.$row_asst2['fname'];
}

$emp_id = $row_num['emp_id'];
$result_emp = mysql_query("SELECT * FROM vehicle_tbl WHERE vehicle_id='".$emp_id."'")
or die("SELECT EMP ".mysql_error());
$row_emp = mysql_fetch_array($result_emp);

$result_comp = mysql_query("SELECT * FROM company_tbl WHERE company_id='".$company_id."'")
or die("SELECT COMPANY ".mysql_error());
$row_comp = mysql_fetch_array($result_comp);
?>
<html>
<head>
<script type="text/javascript">
function print_doc()
{
window.print();
}
</script>
</head>
<body onload='print_doc()'>
<table border='0' width='810' style='font-size:14px;font-family:Times New Roman'>
<tr>
 <th colspan='6' width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['company_name']?></th>
</tr>
<tr>
 <th colspan='6' width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['address']?></th>
</tr>
<tr>
 <td width='33%' style='text-align:left;'>Start Date:_____________</td>
 <td width='34%' style='text-align:center;'><?php echo $row_comp['website']?></td>
 <td width='33%' style='text-align:right;'>Contact No:<?php echo $row_comp['comp_phone']?></td>
</tr>
<tr>
 <td width='33%' style='text-align:left;'>End Date:_____________</td>
 <td width='34%' style='text-align:center;'></td>
 <td width='33%' style='text-align:right;'>Fax No:<?php echo $row_comp['comp_fax']?></td>
</tr>
</table>
<div style="width: 100%; text-align:left;"><img border="0" src="image/rou_rlog.png" width="810" height="30" /></div>
<table border='0' width='810' style='font-size:14px;font-family:Times New Roman'>
<tr>
 <td colspan='1' width='30%' style='text-align:left;'><b>Plate No:</b> <?php echo $row_emp['veh_num']?>
 <br><b>Model:</b> <?php echo $row_emp['year'].' '.$row_emp['manufacturer_name'].' '.$row_emp['model_name']?></td>
 <td colspan='1' width='35%' style='text-align:left;'><b>Driver 1:</b> <?php echo $dr1?>
 <br><b>Assistant 1:</b> <?php echo $asst1?></td>
 <td colspan='1' width='35%' style='text-align:left;'><b>Driver 2:</b> <?php echo $dr2?>
 <br><b>Assistant 2:</b> <?php echo $asst2?></td>
</tr>
</table>
<table border='1' width='810' style='font-size:14px;font-family:Times New Roman'>
<tr>
 <!--<th width='10%' rowspan='2'>Date</th>-->
 <th width='20%' rowspan='2'>Client Name</th>
 <th width='20%' rowspan='2'>Location</th>
 <th width='20%' colspan='2'>Time</th>
 <th width='20%' colspan='2'>Odometer</th>
 <th width='20%' rowspan='2'>Signature</th>
</tr>
<tr>
 <th width='10%'>Departure</th>
 <th width='10%'>Arrival</th>
 <th width='10%'>Departure</th>
 <th width='10%'>Arrival</th>
</tr>
<?php
while($row_select = mysql_fetch_array($result_select))
{
?>
<tr>
 <td width='20%'><?php echo $row_select['client']?>&nbsp;</td>
 <td width='20%'><?php echo $row_select['location']?>&nbsp;</td>
 <td width='10%'>&nbsp;</td>
 <td width='10%'>&nbsp;</td>
 <td width='10%'>&nbsp;</td>
 <td width='10%'>&nbsp;</td>
 <td width='20%'>&nbsp;</td>
</tr>
<?php
}
?>
<p style=" position: absolute; bottom: 0; left: 0; width: 100%; text-align: center;font-size:14px;font-family:Times New Roman"><b><i>Please ask client to sign.<i/><b/></p>
</body>
</html>
<?php
?>